<?php
	//Open gadget, do __MODULE_ID__ replacements
	$gadgetFileName = $_GET['gadget'];
	$fh = fopen($gadgetFileName, 'r') or die("Can't open gadget file - did you specify a gadget via the query string? E.g. http://localhost/IGLocal/ig.php?gadget=myGadget.xml");
	$contents = fread($fh, filesize($gadgetFileName));
	fclose($fh);
	$gadget = simplexml_load_string(str_replace("__MODULE_ID__", "0", $contents));
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>IGLocalhost :: iGoogle Localhost Development Kit by Bonstio</title>
    <script>var _IG_time_epoch = (new Date()).getTime();</script>
    <script src="js/ig.js"></script>
    <script src="js/libminimessage.js"></script>
    <script>var domain = document.location.hostname;
    

    
    _source = "";
    _uli = true;
    _pnlo = false;
    _mpnlo = false;
    _pl = false;
    _mod = true;
    _pid = "";
    _old_html = false;
    _use_old_feed_styles = false;
    _cbp = true;
    _is_dasher = false;
    _upc();
    </script>
    <script><!--
    function save_chkbox_value(hidden_elem_name, checked)
    {
        var hidden_elem = document.getElementById(hidden_elem_name);
        hidden_elem.value = checked ? "1" : "0";
    }
    function RemoteModule(spec_url, id, render_inline, base_iframe_url, caching_disabled)
    {
        this.spec_url = spec_url;
        this.id = id;
        this.render_inline = render_inline;
        this.base_iframe_url = base_iframe_url;
        this.caching_disabled = caching_disabled;
        this.old_width = 0;
        this.wants_scaling = false;
        this.is_inlined = function()
        {
            return this.base_iframe_url == "";
        };
    }
    ;
    var remote_modules = [];

    function ifpc_resizeIframe(iframe_id, height)
    {
        var el = document.getElementById(iframe_id);
        if (el)
        {
            el.style.height = height + "px";
        }
    }
    _IFPC.registerService('resize_iframe', ifpc_resizeIframe);
    function _ig_gmid_(iframe_id)
    {
        return(iframe_id.split("_")[2]);
    }
    function _setModTitle(title, module_id)
    {
        var title_element = _gel("m_" + module_id + "_title");
        if (title_element)
        {
            title_element.innerHTML = _hesc(title);
        }
    }
    function ifpc_setTitle(iframe_id, title)
    {
        if (typeof(iframe_id) == undefined || !iframe_id || iframe_id == "undefined")
        {
            return;
        }
        _setModTitle(title, _ig_gmid_(iframe_id));
    }
    _IFPC.registerService('set_title', ifpc_setTitle);
    function _IG_SetTitle(title, specified_module_id)
    {
        if (typeof(specified_module_id) == "undefined" || !specified_module_id || specified_module_id == "undefined")
        {
            throw new Error("Inline modules must specify their " + "__MODULE_ID__ when using _IG_SetTitle");
        }
        else
        {
            _setModTitle(title, specified_module_id);
        }
    }
    function ifpc_setPref(iframe_id, var_args)
    {
        var module_id = _ig_gmid_(iframe_id);
        var prefs = new _IG_Prefs(module_id);
        var keyValues = new Array();
        for (var n = 1; n < arguments.length; n += 2)
        {
            keyValues.push(arguments[n], arguments[n + 1]);
        }
        prefs.set.apply(prefs, keyValues);
    }
    _IFPC.registerService('set_pref', ifpc_setPref);
    // -->
    </script>
    <link rel="stylesheet" type="text/css" href="css/ig.css"/>
    <style>
    </style>
</head>
<body>
<script>_IG_DD_init();</script>
<script>
<?php

				/**
				Init User Prefs default values
				**/

				foreach ($gadget->UserPref as $up)
				{
					$name = ((string)$up['name']);
					$value = $up['default_value'];

					//Override default UP value with one specified in query string
					@$qValue = $_GET["up_" . $name];
					if ((isset($qValue)) && ($qValue != ""))
					{
						$value = $qValue;
					}

					echo "\t__UP_" . $name . "__ = ";

					switch((string) $up['datatype'])
					{
						// Get attributes as element indices
						case 'list':
							echo "[";
							
							$list = split("\|", $value);
							for ($i = 0; $i < count($list); $i++)
							{
								echo "'" . $list[$i] . "'";
								if ($i+1 < count($list))
								{
									echo ",";
								}
								else
								{
									echo "]";
								}
							}
							
							break;
						
						case 'bool':
							echo $value;

							break;

						case 'enum':
						case 'hidden':
						default:
							echo "'" . $value . "'";
					}

					echo ";\r\n";
				}

			?>


			function _IG_RegisterOnloadHandler(onloadFunction)
			{
				if (onloadFunction) window.onload = onloadFunction;
			}

			function _IG_Analytics(id, path)
			{
				//TODO alphanumeric checking here
			}

			function _gel(id)
			{
				return document.getElementById(id);
			}

			function _IG_Prefs(id)
			{
				_IG_Prefs.prototype.set = function(name, value) 
				{
					eval("__UP_" + name + "__ = '" + value + "'");		
				};

				_IG_Prefs.prototype.getBool = function(name) 
				{
					return eval("__UP_" + name + "__");
				};

				_IG_Prefs.prototype.getInt = function(name) 
				{
					return parseInt(eval("__UP_" + name + "__"));
				};

				_IG_Prefs.prototype.getString = function(name) 
				{
					return eval("__UP_" + name + "__");	
				};

				_IG_Prefs.prototype.getArray = function(name) 
				{
					return eval("__UP_" + name + "__");	
				};
			}

		function ifpc_resizeIframe(iframe_id, height)
		{
			var el = document.getElementById(iframe_id);
			if (el)
			{
				el.style.height = height + "px";
			}
		}

		function _IG_AdjustIFrameHeight()
		{

		}

	</script>

<?php require("gadget.php"); ?>
</body>
</html>











































